package cn.pfz.Utils;

import java.lang.reflect.Field;

public class CharUtil {

    public  static  void convert(Object o ,Class cl)throws Exception{

        Field[] fields = cl.getDeclaredFields();
        for (Field field : fields) {
            //Field  有一个方法isAccessible()   如果他是false  不允许通过返回访问该字段
            if (field.getType() == String.class) {
                field.setAccessible(true);
                String str = (String) field.get(o);
                if (str==null){
                    continue;
                }
                byte[] bytes = str.getBytes("ISO-8859-1");
                field.set(o, new String(bytes, "utf-8"));
            }

        }
    }
}
